package com.jpa.service;

import com.jpa.dao.PersonDao;
import com.jpa.dao.PersonRepositoryDao;
import com.jpa.entity.Person;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p></p>
 *
 * @author Andy
 * @date 2017/8/22
 */
@Service
public class PersonService {

    /*@Autowired
    private PersonDao personDao;*/

    @Autowired
    private PersonRepositoryDao personRepositoryDao;

   /* @Transactional
    public void save(Person p1, Person p2) {
        personDao.save(p1);
        personDao.save(p2);
    }*/

    public Person findByLastName(String lastName) {
        return personRepositoryDao.findByLastName(lastName);
    }

    public List<Person> getPersonList(String lastName, Integer id) {
        return personRepositoryDao.getByLastNameEndingWithAndIdLessThan(lastName, id);
    }

}
